<?php
namespace PsiFramework\Applications\DefaultApp\Classes\Actions\Util;

import("Classes.Actions.AbstractAction");
import("Classes.Util.Object.Identification");

use \PsiFramework\Classes\Actions\AbstractAction;
use \PsiFramework\Classes\Util\Object\File;
use \PsiFramework\Classes\Util\Object\Image;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * The Show Image Action
 *
 * This action is used to show an image
 *
 * @package Actions.Util
 */
class ShowImageAction extends AbstractAction
{

    /**
     * Function executed by the controller
     *
     * It shows the image
     *
     * @return Response the response to the action execution
     */
    public function execute(/*Identification*/ $identification=null)
    {
        parent::execute();
        
        $file = new File();
        
        $imagePath = \getWwwDirectory().'/Images/Default/blank.png';
        if (!isNullOrEmptyString($this->_request->getParameter('display_image'))) {
            $imagePath = $this->_request->getParameter('display_image');
        }
        
        $file->unserialize($imagePath);
        $image = new Image($file);
        
        $this->_response->setAttribute('image', $image);
        
        $this->findForward("success");
    }
}
